package cn.fintecher.pangolin.service.dataimp.web;

import cn.fintecher.pangolin.common.web.BaseController;
import cn.fintecher.pangolin.service.dataimp.model.request.ExportCaseRequest;
import cn.fintecher.pangolin.service.dataimp.model.request.ExportDistributeRequest;
import cn.fintecher.pangolin.service.dataimp.model.request.ExportWorkOrderRequest;
import cn.fintecher.pangolin.service.dataimp.service.DataExportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther: xiaqun
 * @Description: 数据导出相关接口
 * @Date: 17:56 2019/10/15
 */

@RestController
@RequestMapping("/api/dataExportController")
@Api(value = "数据导出相关接口", description = "数据导出相关接口")
public class DataExportController extends BaseController {
    @Autowired
    private DataExportService dataExportService;

    /**
     * 工单导出
     */
    @ApiOperation(value = "工单导出", notes = "工单导出")
    @GetMapping("/exportWorkOrder")
    public ResponseEntity<Void> exportWorkOrder(ExportWorkOrderRequest request,
                                                @RequestHeader(value = "X-UserToken") String token) {
        log.info("REST request to export work order,{}", request);
        dataExportService.exportWorkOrder(request, token);
        return ResponseEntity.ok().build();
    }

    /**
     * 案件导出
     */
    @ApiOperation(value = "案件导出", notes = "案件导出")
    @GetMapping("/exportCase")
    public ResponseEntity<Void> exportCase(ExportCaseRequest request,
                                           @RequestHeader(value = "X-UserToken") String token) {
        log.info("REST request to export case,{}", request);
        dataExportService.exportCase(request, token);
        return ResponseEntity.ok().build();
    }

    /**
     * 催记导出
     */
    @ApiOperation(value = "催记导出", notes = "催记导出")
    @GetMapping("/exportFollowRecord")
    public ResponseEntity<Void> exportFollowRecord(ExportCaseRequest request,
                                                   @RequestHeader(value = "X-UserToken") String token) {
        log.info("REST request to export follow record,{}", request);
        dataExportService.exportFollowRecord(request, token);
        return ResponseEntity.ok().build();
    }

    /**
     * 联系人导出
     */
    @ApiOperation(value = "联系人导出", notes = "联系人导出")
    @GetMapping("/exportContact")
    public ResponseEntity<Void> exportContact(ExportCaseRequest request,
                                              @RequestHeader(value = "X-UserToken") String token) {
        log.info("REST request to export contact,{}", request);
        dataExportService.exportContact(request, token);
        return ResponseEntity.ok().build();
    }

    /**
     * 分案导出
     */
    @ApiOperation(value = "分案导出", notes = "分案导出")
    @GetMapping("/exportDistribute")
    public ResponseEntity<Void> exportDistribute(ExportDistributeRequest request,
                                                 @RequestHeader(value = "X-UserToken") String token) {
        log.info("REST request ot export distribute,{}", request);
        dataExportService.exportDistribute(request, token);
        return ResponseEntity.ok().build();
    }
}
